﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DAL;

/// <summary>
///UserGuid 的摘要说明
/// </summary>
public class UserGuid
{
    public UserGuid()
    {
        
        //
        //TODO: 在此处添加构造函数逻辑
        //
    }
    public static Guid GetUserID(string userName)
    {
        UserGuidDataContext db = new UserGuidDataContext();
        var result=(from obj in db.UserGuid where obj.UserID==userName select obj).FirstOrDefault();
        if(result==null)
        {
            Guid ID=Guid.NewGuid();
            DAL.UserGuid user=new DAL.UserGuid();
            user.ID=ID;
            user.UserID=userName;
            db.UserGuid.InsertOnSubmit(user);
            db.SubmitChanges();
            return ID;

        }
        else
        {
            return result.ID;
        }
        
    
    }
}
